//
//  DataStoreService.h
//  QuXiang
//
//  Created by Duncan on 2020/6/22.
//  Copyright © 2020 NanHuaiZi. All rights reserved.
//

#import <Foundation/Foundation.h>

#pragma mark ------- 用户表 -------
static NSString * _Nullable const kDataStoreToken = @"kDataStoreToken"; // token

#pragma mark ------- 设备表 -------
static NSString * _Nullable const kDataStoreUUID = @"kDataStoreUUID"; 
static NSString * _Nullable const kDataStoreReceiptData = @"kDataStoreReceiptData"; // 内购票据
static NSString * _Nullable const kDataStoreReceipOrderID = @"kDataStoreReceipOrderID"; // 内购订单ID
static NSString * _Nullable const kDataStoreReceipNeed_OrderID = @"kDataStoreReceipNeed_OrderID"; // 内购订单ID
static NSString * _Nullable const kDataStoreReceipTransactionIdentifier = @"kDataStoreReceipTransactionIdentifier"; // 内购票据ID
static NSString * _Nullable const kDataStoreReceipAutomatic = @"kDataStoreReceipAutomatic"; // 内购是否自动续订
static NSString * _Nullable const kDataStoreBenDiVip = @"kDataStoreBenDiVip"; // 本地Vip

typedef NS_ENUM(NSUInteger, DataStoreTableType) {
    User = 1,// 用户表
    Device = 2, // 设备表
};

NS_ASSUME_NONNULL_BEGIN
// 数据存储service
@interface DataStoreService : NSObject

#pragma mark 存/改
+ (void)putString:(NSString *)string withId:(NSString *)stringId intoTable:(DataStoreTableType)tableName;
+ (void)putNumber:(NSNumber *)number withId:(NSString *)numberId intoTable:(DataStoreTableType)tableName;
+ (void)putObject:(id)object withId:(NSString *)objectId intoTable:(DataStoreTableType)tableName;
+ (void)putModel:(id)model withId:(NSString *)modelId intoTable:(DataStoreTableType)tableName;

#pragma mark 取
+ (NSArray *)getAllModelFromTable:(DataStoreTableType)tableName;
+ (NSArray *)getAllModelFromTable:(DataStoreTableType)tableName className:(Class)className;
+ (NSString *)getStringById:(NSString *)stringId fromTable:(DataStoreTableType)tableName;
+ (NSNumber *)getNumberById:(NSString *)numberId fromTable:(DataStoreTableType)tableName;
+ (id)getObjectById:(NSString *)objectId fromTable:(DataStoreTableType)tableName;
+ (id)getModelById:(NSString *)modelId className:(Class)className fromTable:(DataStoreTableType)tableName;

#pragma mark 删
+ (void)deleteObjectById:(NSString *)objectId fromTable:(DataStoreTableType)tableName;
+ (void)clearTable:(DataStoreTableType)tableName;

@end

NS_ASSUME_NONNULL_END
